package lambda.string;

public class ChatAtDemo {
    public static void main(String[] args) {
        // 获取        01234567890
        String str = "www.tedu.cn";
        char c = str.charAt(4);
        System.out.println(c);

        for (int i = 0; i < str.length(); i++) {
            c = str.charAt(i);
            System.out.println(c);
        }
        String line = "上海自来水来自海上";

//        //第一个和倒数第一个(上)
//        char c1=line.charAt(0);
//        char c2=line.charAt(8);
//
//        //第二组(海)
//        c1 = line.charAt(1);
//        c2 = line.charAt(7);
//
//        //第三组(自)
//        c1 = line.charAt(2);
//        c2 = line.charAt(6);
//
//        //第四组(来)
//        c1 = line.charAt(3);
//        c2 = line.charAt(5);
                /*int i=0;
        for(;i<line.length()/2;i++){
            char c1 = line.charAt(i);
            char c2 = line.charAt(line.length()-1-i);
            if(c1!=c2){
                System.out.println("不是回文");
                break;
            }
        }
        if(i==line.length()/2) {
            System.out.println("是回文");
        }*/

        /*boolean check = true;//默认是回文
        for(int i=0;i<line.length()/2;i++){
            char c1 = line.charAt(i);
            char c2 = line.charAt(line.length()-1-i);
            if(c1!=c2){
                System.out.println("不是回文");
                check = false;
                break;
            }
        }
        if(check) {
            System.out.println("是回文");
        }*/

        /*for(int i=0;i<line.length()/2;i++){
            char c1 = line.charAt(i);
            char c2 = line.charAt(line.length()-1-i);
            if(c1!=c2){
                System.out.println("不是回文");
                return;
            }
        }
        System.out.println("是回文");*/

        for (int i = 0; i < line.length() / 2; i++) {
            char c1 = line.charAt(i);
            char c2 = line.charAt(line.length() - 1 - i);
            if (c1 != c2) {
                System.out.print("不");
                break;
            }
        }
        System.out.println("是回文");

    }

}
